\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{textcircled}[2018/11/11 v1.00 well-designed (TeX)]

\RequirePackage{tikz}
\RequirePackage{xparse}
\RequirePackage{calc}

\newlength{\textcircled@textwidth}%
\newlength{\textcircled@textheight}%
\newlength{\textcircled@numwidth@two}%
\newlength{\textcircled@numwidth@three}%

\DeclareDocumentCommand{\tikztextcircle}{O{white} o m}{%
    \settoheight{\textcircled@textheight}{#3}%
    \settowidth{\textcircled@numwidth@two}{88}%获取标准2位数宽度
    \settowidth{\textcircled@numwidth@three}{888}%获取标准3位数宽度
    \settowidth{\textcircled@textwidth}{#3}% 获取文本宽度
    \tikz[baseline,outer sep=0pt,inner sep=0pt]{%
        \pgfmathparse{%
            ifthenelse(\textcircled@textwidth < \textcircled@numwidth@two, 0.8, ifthenelse(\textcircled@textwidth < \textcircled@numwidth@three, 0.6, 0.5))%
        }%
        \let\hfs\pgfmathresult%
        \draw[fill=#1] (0,\textcircled@textheight/2) circle (\textcircled@textheight/2+0.3ex);%
        \IfNoValueTF{#2}{%
            \node at (0,\textcircled@textheight/2) {%
                \makebox[0em][c]{\scalebox{\hfs}[\hfs]{#3}}%
            };%
        }{%
            \node[text=#2] at (0,\textcircled@textheight/2) {%
                \makebox[0em][c]{\scalebox{\hfs}[\hfs]{#3}}%
            };%
        }%
    }%
}%

\endinput
%%
%% End of file `textcircled.sty'.